// 初始化
function applyCollect() {
    $(".form-collect").jQValidator({
        isClearForm: false,
        excluded: ':disabled',
        fields: {
            applySuggest: {
                validators: {
                    notEmpty: {
                        message: '此项为必填项'
                    }
                }
            },
            applyTel: {
                validators: {
                    notEmpty: {
                        message: '请填写您的手机号'
                    },
                    phone: {
                        phoneType: 'MB'
                    }
                }
            },
            applyName: {
                validators: {
                    notEmpty: {
                        message: '请填写您的姓名'
                    },
                }
            },
            applyWork: {
                validators: {
                    notEmpty: {
                        message: '请填写您的工作单位'
                    },
                }
            },
            applyVcode: {
                validators: {
                    notEmpty: {
                        message: '请填写验证码'
                    },
                }
            },
        }
    });
}

$('.btn-hrapply').on(tap, function() {
    $('#modalHrbox').modal('show');
});
// $('#modalHrbox').on('shown.bs.modal', function() {
//     applyForm();
// })
$(window).on("load", function() {
    applyCollect();
});



// 表单提交
$('.form-collect .btn-submit').on('click', function() {
    /// 点击提交按钮进行校验
    var isValid;
    var jQValidator = $(".form-collect").data('jQValidator');
    jQValidator.validate();

    /// bool, 所有字段验证是否正确
    var isValid = $('.form-collect').data('jQValidator').isValid();


    if (isValid) {
        // 提交成功弹窗
        $('.p-collect #modalTipsSuc').show()

        $('.p-collect #modalTipsSuc').css('opacity', '1')

    } else {
        // 提交错误弹窗
        $('.p-collect #modalTipsError').show()
        $('.p-collect #modalTipsSuc').css('opacity', '1')
    }
});

// 表单关闭
$('.p-collect .btn-sure').on('click', function() {
    $(this).parents('.modal-tips').hide()
    $(this).parents('.modal-tips').css('opacity', '0')
    $('.p-collect .animbox').hide()
})